<!DOCTYPE HTML>
<html>

<head>
	<link rel="bookmark"  type="image/x-icon"  href="/img/logo_miccall.png"/>
	<link rel="shortcut icon" href="/img/logo_miccall.png">
	
			    <title>
    Ame雨
    </title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
    <link rel="stylesheet" href="/amelin-ting/css/mic_main.css" />
    <link rel="stylesheet" href="/amelin-ting/css/dropdownMenu.css" />
    <meta name="keywords" content="Ame雨" />
    
    	<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
	 
    <noscript>
        <link rel="stylesheet" href="/amelin-ting/css/noscript.css" />
    </noscript>
    <style type="text/css">
        body:before {
          content: ' ';
          position: fixed;
          top: 0;
          background: url('/amelin-ting/img/bg.jpg') center 0 no-repeat;
          right: 0;
          bottom: 0;
          left: 0;
          background-size: cover; 
        }
    </style>

			    
  
    <script type="text/x-mathjax-config">
      MathJax.Hub.Config({
        tex2jax: {
          inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
          processEscapes: true,
          skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
        }
      });
    </script>

    <script type="text/x-mathjax-config">
      MathJax.Hub.Queue(function() {
        var all = MathJax.Hub.getAllJax(), i;
        for (i=0; i < all.length; i += 1) {
          all[i].SourceElement().parentNode.className += ' has-jax';
        }
      });
    </script>
    <script async type="text/javascript" src="//cdn.bootcss.com/mathjax/2.7.1/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
  


    <script src="/amelin-ting/js/jquery.min.js"></script>
    <script src="/amelin-ting/js/jquery.scrollex.min.js"></script>
    <script src="/amelin-ting/js/jquery.scrolly.min.js"></script>
    <script src="/amelin-ting/js/skel.min.js"></script>
    <script src="/amelin-ting/js/util.js"></script>
    <script src="/amelin-ting/js/main.js"></script>
	
<meta name="generator" content="Hexo 5.4.0"></head>
    
		
<!-- Layouts -->



<!--  代码渲染  -->
<link rel="stylesheet" href="/css/prism_coy.css" />
<link rel="stylesheet" href="/css/typo.css" />
<!-- 文章页 -->
<body class="is-loading">
    <!-- Wrapper 外包 s-->
    <div id="wrapper" class="fade-in">
        <!-- Intro 头部显示 s -->
        <!-- Intro 头部显示 e -->
        <!-- Header 头部logo start -->
        <header id="header">
    <a href="/amelin-ting/" class="logo">Art Space</a>
</header>
        <!-- Nav 导航条 start -->
        <nav id="nav" class="special" >
            <ul class="menu links" >
			<!-- Homepage  主页  --> 
			<li >
	            <a href="/amelin-ting/" rel="nofollow">主页</a>
	        </li>
			<!-- categories_name  分类   --> 
	        
	        <li class="active">
	            <a href="#s1">分类</a>
	                    <ul class="submenu">
	                        <li>
	                        <a class="category-link" href="/amelin-ting/categories/Go/">Go</a></li><li><a class="category-link" href="/amelin-ting/categories/django/">django</a></li><li><a class="category-link" href="/amelin-ting/categories/drf/">drf</a></li><li><a class="category-link" href="/amelin-ting/categories/gin/">gin</a></li><li><a class="category-link" href="/amelin-ting/categories/go/">go</a></li><li><a class="category-link" href="/amelin-ting/categories/linux/">linux</a></li><li><a class="category-link" href="/amelin-ting/categories/mysql/">mysql</a></li><li><a class="category-link" href="/amelin-ting/categories/python/">python</a></li><li><a class="category-link" href="/amelin-ting/categories/%E5%86%85%E7%BD%91%E7%A9%BF%E9%80%8F/">内网穿透</a></li><li><a class="category-link" href="/amelin-ting/categories/%E5%89%8D%E7%AB%AF/">前端</a>
	                    </ul>
	        </li>
	        
	        <!-- archives  归档   --> 
	        
	        
		        <!-- Pages 自定义   -->
		        
		        <li>
		            <a href="/about/" title="简历">
		                简历
		            </a>
		        </li>
		        
		        <li>
		            <a href="/group/" title="团队">
		                团队
		            </a>
		        </li>
		        
		        <li>
		            <a href="/gallery/" title="图库">
		                图库
		            </a>
		        </li>
		        
		        <li>
		            <a href="/tag/" title="标签">
		                标签
		            </a>
		        </li>
		        


            </ul>
            <!-- icons 图标   -->
			<ul class="icons">
                    
                    <li>
                        <a title="github" href="https://github.com/miccall" target="_blank" rel="noopener">
                            <i class="icon fa fa-github"></i>
                        </a>
                    </li>
                    
                    <li>
                        <a title="500px" href="http://500px.com" target="_blank" rel="noopener">
                            <i class="icon fa fa-500px"></i>
                        </a>
                    </li>
                    
			</ul>
</nav>

        <div id="main" >
            <div class ="post_page_title_img" style="height: 25rem;background-image: url(https://img2.baidu.com/it/u=4028229870,4072935031&amp;fm=26&amp;fmt=auto);background-position: center; background-repeat:no-repeat; background-size:cover;-moz-background-size:cover;overflow:hidden;" >
                <a href="#" style="padding: 4rem 4rem 2rem 4rem ;"><h2 >fmt语言标准库</h2></a>
            </div>
            <!-- Post -->
            <div class="typo" style="padding: 3rem;">
                <h2 id="一、fmt"><a href="#一、fmt" class="headerlink" title="一、fmt"></a>一、fmt</h2><figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// fmt标准库是我们在学习Go语言过程中接触最早最频繁的一个</span></span><br><span class="line"><span class="comment">// fmt包实现类似C语言print和scanf的格式化I/O。主要分为向外输出内容和获取输入内容两大部分</span></span><br></pre></td></tr></table></figure>

<h2 id="二、向外输出"><a href="#二、向外输出" class="headerlink" title="二、向外输出"></a>二、向外输出</h2><h3 id="2-1-Print"><a href="#2-1-Print" class="headerlink" title="2.1  Print"></a>2.1  Print</h3><figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// Print系列函数会将内容输出到系统的标准输出，区别在于Print函数直接输出内容，Printf函数支持格式化输出字符串，Println函数会在输出内容的结尾添加一个换行符。</span></span><br><span class="line"><span class="number">1.</span> 代码演示</span><br><span class="line">    <span class="function"><span class="keyword">func</span> <span class="title">main</span><span class="params">()</span></span> &#123;</span><br><span class="line">        fmt.Print(<span class="string">&quot;Ame--------&quot;</span>)</span><br><span class="line">        name := <span class="string">&quot;Ame雨雨雨&quot;</span></span><br><span class="line">        fmt.Printf(<span class="string">&quot;我是：%s\n&quot;</span>, name)</span><br><span class="line">        fmt.Println(<span class="string">&quot;Ame-------&quot;</span>)</span><br><span class="line">    &#125;</span><br></pre></td></tr></table></figure>

<h3 id="2-2-Fprint"><a href="#2-2-Fprint" class="headerlink" title="2.2 Fprint"></a>2.2 Fprint</h3><figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// Fprint系列函数会将内容输出到一个io.Writer接口类型的变量w中，我们通常用这个函数往文件中写入内容。</span></span><br><span class="line"><span class="number">1.</span> 代码演示</span><br><span class="line"><span class="comment">// 向标准输出写入内容</span></span><br><span class="line">    fmt.Fprintln(os.Stdout, <span class="string">&quot;向标准输出写入内容&quot;</span>)</span><br><span class="line">    fileObj, err := os.OpenFile(<span class="string">&quot;./xx.txt&quot;</span>, os.O_CREATE|os.O_WRONLY|os.O_APPEND, <span class="number">0644</span>)</span><br><span class="line">    <span class="keyword">if</span> err != <span class="literal">nil</span> &#123;</span><br><span class="line">        fmt.Println(<span class="string">&quot;打开文件出错，err:&quot;</span>, err)</span><br><span class="line">        <span class="keyword">return</span></span><br><span class="line">    &#125;</span><br><span class="line">    name := <span class="string">&quot;沙河小王子&quot;</span></span><br><span class="line">    <span class="comment">// 向打开的文件句柄中写入内容</span></span><br><span class="line">    fmt.Fprintf(fileObj, <span class="string">&quot;往文件中写如信息：%s&quot;</span>, name)</span><br><span class="line"></span><br><span class="line"><span class="comment">// 注意，只要满足io.Writer接口的类型都支持写入</span></span><br></pre></td></tr></table></figure>

<h3 id="2-3-Sprint"><a href="#2-3-Sprint" class="headerlink" title="2.3 Sprint"></a>2.3 Sprint</h3><figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// Sprint系列函数会把传入的数据生成并返回一个字符串。</span></span><br><span class="line"><span class="number">1.</span> 代码演示</span><br><span class="line">    s1 := fmt.Sprint(<span class="string">&quot;Ame雨雨雨&quot;</span>)</span><br><span class="line">    name := <span class="string">&quot;Ame雨雨雨&quot;</span></span><br><span class="line">    age := <span class="number">18</span></span><br><span class="line">    s2 := fmt.Sprintf(<span class="string">&quot;name:%s,age:%d&quot;</span>, name, age)</span><br><span class="line">    s3 := fmt.Sprintln(<span class="string">&quot;Ame雨雨雨&quot;</span>)</span><br><span class="line">    fmt.Println(s1, s2, s3)</span><br></pre></td></tr></table></figure>

<h3 id="2-4-Errorf"><a href="#2-4-Errorf" class="headerlink" title="2.4 Errorf"></a>2.4 Errorf</h3><figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// Errorf函数根据format参数生成格式化字符串并返回一个包含该字符串的错误</span></span><br><span class="line"><span class="number">1.</span> 代码演示</span><br><span class="line">	err := fmt.Errorf(<span class="string">&quot;这是一个错误&quot;</span>)</span><br><span class="line"><span class="comment">// Go1.13版本为fmt.Errorf函数新加了一个%w占位符用来生成一个可以包裹Error的Wrapping Error</span></span><br><span class="line">    e := errors.New(<span class="string">&quot;原始错误e&quot;</span>)</span><br><span class="line">    w := fmt.Errorf(<span class="string">&quot;Wrap了一个错误%w&quot;</span>, e)</span><br></pre></td></tr></table></figure>

<h2 id="三、格式化占位符"><a href="#三、格式化占位符" class="headerlink" title="三、格式化占位符"></a>三、格式化占位符</h2><figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// *printf系列函数都支持format格式化参数，在这里我们按照占位符将被替换的变量类型划分，方便查询和记忆</span></span><br></pre></td></tr></table></figure>

<h3 id="3-1-通用占位符"><a href="#3-1-通用占位符" class="headerlink" title="3.1 通用占位符"></a>3.1 通用占位符</h3><figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">%v	值的默认格式表示</span><br><span class="line">%+v	类似%v，但输出结构体时会添加字段名</span><br><span class="line">%#v	值的Go语法表示</span><br><span class="line">%T	打印值的类型</span><br><span class="line">%%	百分号</span><br></pre></td></tr></table></figure>

<h3 id="3-2-布尔型"><a href="#3-2-布尔型" class="headerlink" title="3.2 布尔型"></a>3.2 布尔型</h3><figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">%t	<span class="literal">true</span>或<span class="literal">false</span></span><br></pre></td></tr></table></figure>

<h3 id="3-3-整型"><a href="#3-3-整型" class="headerlink" title="3.3 整型"></a>3.3 整型</h3><figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">%b	表示为二进制</span><br><span class="line">%c	该值对应的unicode码值</span><br><span class="line">%d	表示为十进制</span><br><span class="line">%o	表示为八进制</span><br><span class="line">%x	表示为十六进制，使用a-f</span><br><span class="line">%X	表示为十六进制，使用A-F</span><br><span class="line">%U	表示为Unicode格式：U+<span class="number">1234</span>，等价于”U+%<span class="number">04</span>X”</span><br><span class="line">%q	该值对应的单引号括起来的<span class="keyword">go</span>语法字符字面值，必要时会采用安全的转义表示</span><br></pre></td></tr></table></figure>

<h3 id="3-4-浮点数与复数"><a href="#3-4-浮点数与复数" class="headerlink" title="3.4 浮点数与复数"></a>3.4 浮点数与复数</h3><figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">%b	无小数部分、二进制指数的科学计数法，如<span class="number">-123456</span>p<span class="number">-78</span></span><br><span class="line">%e	科学计数法，如<span class="number">-1234.456e+78</span></span><br><span class="line">%E	科学计数法，如<span class="number">-1234.456E+78</span></span><br><span class="line">%f	有小数部分但无指数部分，如<span class="number">123.456</span></span><br><span class="line">%F	等价于%f</span><br><span class="line">%g	根据实际情况采用%e或%f格式（以获得更简洁、准确的输出）</span><br><span class="line">%G	根据实际情况采用%E或%F格式（以获得更简洁、准确的输出）</span><br></pre></td></tr></table></figure>

<h3 id="3-5-字符串和-byte"><a href="#3-5-字符串和-byte" class="headerlink" title="3.5 字符串和[]byte"></a>3.5 字符串和[]byte</h3><figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">%s	直接输出字符串或者[]<span class="keyword">byte</span></span><br><span class="line">%q	该值对应的双引号括起来的<span class="keyword">go</span>语法字符串字面值，必要时会采用安全的转义表示</span><br><span class="line">%x	每个字节用两字符十六进制数表示（使用a-f</span><br><span class="line">%X	每个字节用两字符十六进制数表示（使用A-F</span><br></pre></td></tr></table></figure>

<h3 id="3-6-指针"><a href="#3-6-指针" class="headerlink" title="3.6 指针"></a>3.6 指针</h3><figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">%p	表示为十六进制，并加上前导的<span class="number">0</span>x</span><br></pre></td></tr></table></figure>

<h3 id="3-7-宽度标识符"><a href="#3-7-宽度标识符" class="headerlink" title="3.7 宽度标识符"></a>3.7 宽度标识符</h3><figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 宽度通过一个紧跟在百分号后面的十进制数指定，如果未指定宽度，则表示值时除必需之外不作填充。精度通过（可选的）宽度后跟点号后跟的十进制数指定。如果未指定精度，会使用默认精度；如果点号后没有跟数字，表示精度为0。</span></span><br><span class="line">%f	默认宽度，默认精度</span><br><span class="line">%<span class="number">9</span>f	宽度<span class="number">9</span>，默认精度</span><br><span class="line">%<span class="number">.2</span>f	默认宽度，精度<span class="number">2</span></span><br><span class="line">%<span class="number">9.2</span>f	宽度<span class="number">9</span>，精度<span class="number">2</span></span><br><span class="line">%<span class="number">9.</span>f	宽度<span class="number">9</span>，精度</span><br></pre></td></tr></table></figure>

<h3 id="3-8-其他flag"><a href="#3-8-其他flag" class="headerlink" title="3.8 其他flag"></a>3.8 其他flag</h3><figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">’+’	总是输出数值的正负号；对%q（%+q）会生成全部是ASCII字符的输出（通过转义）；</span><br><span class="line">’ ‘	对数值，正数前加空格而负数前加负号；对字符串采用%x或%X时（% x或% X）会给各打印的字节之间加空格</span><br><span class="line">’-’	在输出右边填充空白而不是默认的左边（即从默认的右对齐切换为左对齐）；</span><br><span class="line">’#’	八进制数前加<span class="number">0</span>（%#o），十六进制数前加<span class="number">0</span>x（%#x）或<span class="number">0</span>X（%#X），指针去掉前面的<span class="number">0</span>x（%#p）对%q（%#q），对%U（%#U）会输出空格和单引号括起来的<span class="keyword">go</span>字面值；</span><br><span class="line">‘<span class="number">0</span>’	使用<span class="number">0</span>而不是空格填充，对于数值类型会把填充的<span class="number">0</span>放在正负号后面；</span><br><span class="line">举个例子：</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h2 id="四、获取输入"><a href="#四、获取输入" class="headerlink" title="四、获取输入"></a>四、获取输入</h2><figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// Go语言fmt包下有fmt.Scan、fmt.Scanf、fmt.Scanln三个函数，可以在程序运行过程中从标准输入获取用户的输入。</span></span><br></pre></td></tr></table></figure>

<h3 id="4-1-fmt-Scan"><a href="#4-1-fmt-Scan" class="headerlink" title="4.1 fmt.Scan"></a>4.1 fmt.Scan</h3><figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/*</span></span><br><span class="line"><span class="comment">Scan从标准输入扫描文本，读取由空白符分隔的值保存到传递给本函数的参数中，换行符视为空白符。</span></span><br><span class="line"><span class="comment">本函数返回成功扫描的数据个数和遇到的任何错误。如果读取的数据个数比提供的参数少，会返回一个错误报告原因。</span></span><br><span class="line"><span class="comment">*/</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">func</span> <span class="title">main</span><span class="params">()</span></span> &#123;</span><br><span class="line">	<span class="keyword">var</span> (</span><br><span class="line">		name    <span class="keyword">string</span></span><br><span class="line">		age     <span class="keyword">int</span></span><br><span class="line">		married <span class="keyword">bool</span></span><br><span class="line">	)</span><br><span class="line">	fmt.Scan(&amp;name, &amp;age, &amp;married)</span><br><span class="line">	fmt.Printf(<span class="string">&quot;扫描结果 name:%s age:%d married:%t \n&quot;</span>, name, age, married)</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h3 id="4-2-fmt-Scanf"><a href="#4-2-fmt-Scanf" class="headerlink" title="4.2 fmt.Scanf"></a>4.2 fmt.Scanf</h3><figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/*</span></span><br><span class="line"><span class="comment">Scanf从标准输入扫描文本，根据format参数指定的格式去读取由空白符分隔的值保存到传递给本函数的参数中。</span></span><br><span class="line"><span class="comment">本函数返回成功扫描的数据个数和遇到的任何错误。</span></span><br><span class="line"><span class="comment">*/</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">func</span> <span class="title">main</span><span class="params">()</span></span> &#123;</span><br><span class="line">	<span class="keyword">var</span> (</span><br><span class="line">		name    <span class="keyword">string</span></span><br><span class="line">		age     <span class="keyword">int</span></span><br><span class="line">		married <span class="keyword">bool</span></span><br><span class="line">	)</span><br><span class="line">	fmt.Scanf(<span class="string">&quot;1:%s 2:%d 3:%t&quot;</span>, &amp;name, &amp;age, &amp;married)</span><br><span class="line">	fmt.Printf(<span class="string">&quot;扫描结果 name:%s age:%d married:%t \n&quot;</span>, name, age, married)</span><br><span class="line">&#125;</span><br><span class="line">fmt.Scanf不同于fmt.Scan简单的以空格作为输入数据的分隔符，fmt.Scanf为输入数据指定了具体的输入内容格式，只有按照格式输入数据才会被扫描并存入对应变量。</span><br></pre></td></tr></table></figure>

<h3 id="4-3-fmt-Scanln"><a href="#4-3-fmt-Scanln" class="headerlink" title="4.3 fmt.Scanln"></a>4.3 fmt.Scanln</h3><figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/*</span></span><br><span class="line"><span class="comment">func Scanln(a ...interface&#123;&#125;) (n int, err error)</span></span><br><span class="line"><span class="comment">Scanln类似Scan，它在遇到换行时才停止扫描。最后一个数据后面必须有换行或者到达结束位置。</span></span><br><span class="line"><span class="comment">本函数返回成功扫描的数据个数和遇到的任何错误。</span></span><br><span class="line"><span class="comment">*/</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">func</span> <span class="title">main</span><span class="params">()</span></span> &#123;</span><br><span class="line">	<span class="keyword">var</span> (</span><br><span class="line">		name    <span class="keyword">string</span></span><br><span class="line">		age     <span class="keyword">int</span></span><br><span class="line">		married <span class="keyword">bool</span></span><br><span class="line">	)</span><br><span class="line">	fmt.Scanln(&amp;name, &amp;age, &amp;married)</span><br><span class="line">	fmt.Printf(<span class="string">&quot;扫描结果 name:%s age:%d married:%t \n&quot;</span>, name, age, married)</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>


            </div>

            <!-- Post Comments -->
            
    <!-- 使用 DISQUS_CLICK -->
<div id="disqus-comment">
    <div id="disqus_thread"></div>

<!-- add animation -->
<style>
	.disqus_click_btn {
            line-height: 30px;
            margin: 0;
            min-width: 50px;
            padding: 0 14px;
            display: inline-block;
            font-family: "Roboto", "Helvetica", "Arial", sans-serif;
            font-size: 14px;
            font-weight: 400;
            text-transform: uppercase;
            letter-spacing: 0;
            overflow: hidden;
            will-change: box-shadow;
            transition: box-shadow .2s cubic-bezier(.4, 0, 1, 1), background-color .2s cubic-bezier(.4, 0, .2, 1), color .2s cubic-bezier(.4, 0, .2, 1);
            outline: 0;
            cursor: pointer;
            text-decoration: none;
            text-align: center;
            vertical-align: middle;
            border: 0;
            background: rgba(158, 158, 158, .2);
            box-shadow: 0 2px 2px 0 rgba(0, 0, 0, .14), 0 3px 1px -2px rgba(0, 0, 0, .2), 0 1px 5px 0 rgba(0, 0, 0, .12);
            color: #fff;
            background-color: #7EC0EE;
            text-shadow: 0
        }
</style>
	
<div class="btn_click_load" id="disqus_bt"> 
    <button class="disqus_click_btn">点击查看评论</button>
</div>

<!--
<script type="text/javascript">
$('.btn_click_load').click(function() {
    /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
    var disqus_shortname = 'http-miccall-tech'; // required: replace example with your forum shortname

    /* * * DON'T EDIT BELOW THIS LINE * * */
    (function() {
      var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
      dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
      (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
    })();

    document.getElementById('disqus_bt').style.display = "none";
});
</script>
-->
<script type="text/javascript">
    var disqus_config = function () {
        this.page.url = 'https://gitee.com/AmeX/amelin-ting.git/2002/05/06/Go%E8%AF%AD%E8%A8%80%E6%A0%87%E5%87%86%E5%BA%93------fmt/';  // Replace PAGE_URL with your page's canonical URL variable
        this.page.identifier = 'https://gitee.com/AmeX/amelin-ting.git/2002/05/06/Go%E8%AF%AD%E8%A8%80%E6%A0%87%E5%87%86%E5%BA%93------fmt/'; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
    };
</script>

<script type="text/javascript">
    $('.btn_click_load').click(function() {  //click to load comments
        (function() { // DON'T EDIT BELOW THIS LINE
            var d = document;
            var s = d.createElement('script');
            s.src = '//http-miccall-tech.disqus.com/embed.js';
            s.setAttribute('data-timestamp', + new Date());
            (d.head || d.body).appendChild(s);
        })();
        $('.btn_click_load').css('display','none');
    });
</script>
</div>
<style>
    #disqus-comment{
        background-color: #eee;
        padding: 2pc;
    }
</style>


        </div>
        <!-- Copyright 版权 start -->
                <div id="copyright">
            <ul>
                <li>&copy;Powered By <a target="_blank" rel="noopener" href="https://hexo.io/zh-cn/" style="border-bottom: none;">hexo</a></li>
                <li>Design: <a target="_blank" rel="noopener" href="http://miccall.tech " style="border-bottom: none;">miccall</a></li>
            </ul>
            
                <span id="busuanzi_container_site_pv">本站总访问量<span id="busuanzi_value_site_pv"></span>次</span>
			
        </div>
    </div>
</body>



 	
</html>
